clear
NumMethod = 4;
rep = 100;
mean_budget = zeros(NumMethod,4); % prsmmo, prsmmo+ls, mommop, lamsaco
var_budget = zeros(NumMethod,4);
samples = zeros(rep,4,NumMethod); % [rep, epsilon, method]
ProblemName = 'EqualMinima';
% 'EqualMinima','Himmelblau','Sixhump','ModifiedRastrigin','Vincent',
% 'Shubert','Composition','IncreasingMinima','Rastrigin','Schaffer'.

work_space = load(['prsmmo\extract\a0.3_n4_10_d3\',ProblemName,'.mat']);
samples(:,:,1) = work_space.TotalBudget;
mean_budget(1,:) = mean(samples(:,:,1),1);
var_budget(1,:) = var(samples(:,:,1),[],1);

work_space = load(['prsmmo_ls\a0.3_n4_10_d3\',ProblemName,'.mat']);
samples(:,:,2) = work_space.TotalBudget1+work_space.TotalBudget2;
mean_budget(2,:) = mean(samples(:,:,2),1);
var_budget(2,:) = var(samples(:,:,2),[],1);

work_space = load(['mommop\data\',ProblemName,'.mat']);
samples(:,:,3) = work_space.TotalBudget;
mean_budget(3,:) = mean(samples(:,:,3),1);
var_budget(3,:) = var(samples(:,:,3),[],1);

work_space = load(['lamsaco\v3\',ProblemName,'.mat']);
samples(:,:,4) = work_space.TotalBudget;
mean_budget(4,:) = mean(samples(:,:,4),1);
var_budget(4,:) = var(samples(:,:,4),[],1);

%% CS two sample t test
% alpha = 0.05/3;
% CS_best_method = zeros(1,4);
% CS_significant = zeros(NumMethod,4); % 1: better
% CS_normality_test = zeros(NumMethod,4); % 1: normal
% CS_p = zeros(NumMethod,4);
% for i = 1:4
%     [~,best_method(i)] = min(mean_budget(:,i));
%     for j = 1:NumMethod
%         CS_normality_test(j,i) = 1-jbtest(samples(:,i,j));
%         [CS_significant(j,i),CS_p(j,i)] = ttest2(samples(:,i,best_method(i)),samples(:,i,j),'alpha',alpha,'Tail','left','Vartype','unequal');
%     end
% end

%% CS Wilcoxon rank sum test
alpha = 0.05/(NumMethod-1);
CS_best_method = zeros(1,4);
CS_significant = zeros(NumMethod,4); % 1: better
CS_p = zeros(NumMethod,4);
for i = 1:4
    [~,CS_best_method(i)] = min(mean_budget(:,i));
    for j = 1:NumMethod
        [CS_p(j,i),CS_significant(j,i)] = ranksum(samples(:,i,CS_best_method(i)),samples(:,i,j),'alpha',alpha,'Tail','left');
    end
end
